/**
 * 版本信息
 */
define([
    '../../../app/framework/bean/version',
    '../../../app/framework/bean/user'
], function(
    versionModel,
    userModel
) {
    var version = {
        init: function() {
            var _this = this;
            _this.loadVersionData();
        },

        /*
         @获取版本信息数据
         */
        loadVersionData: function() {
            var _this = this;
            var _timelineBodyArea = $('#timeline-body-area'),
                _tmpHtml = '<span class="center-line"></span>';
            userModel.queryUser(function(user) {
                var params = {
                    language: user.language
                }
                versionModel.getVersionInfoList(params, function(result) {
                    $.each(result, function(i, v) {
                        _tmpHtml += '<div class="cd-timeline-block';
                        if (!v.isInner) {
                            _tmpHtml += '">';
                        } else {
                            _tmpHtml += ' cd-float-right">';
                        }
                        _tmpHtml += '<div class="cd-timeline-img ';
                        if (!v.isInner) {
                            _tmpHtml += ' cd-outer"></div>';
                        } else {
                            _tmpHtml += ' cd-inner"></div>';
                        }
                        _tmpHtml += '<div class="cd-timeline-content">';
                        _tmpHtml += "<h2>";
                        _tmpHtml += v.version;
                        _tmpHtml += "</h2>";
                        _tmpHtml += "<ul>";
                        _tmpHtml += '<li>' + v.body + '</li>';
                        _tmpHtml += '</ul>';
                        _tmpHtml += '<span class="cd-date">' + v.createTime + "</span></div></div>";
                    });
                    _timelineBodyArea.html(_tmpHtml);
                });
            })
        }
    }
    return version;
});
